package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/13 14:49
 * @description
 */
public class Code633 {
    public static void main(String[] args) {
        System.out.println(new Code633().judgeSquareSum(5));
    }

    public boolean judgeSquareSum(int c) {
        int h = (int)Math.sqrt(c), l = 0;
        while (l <= h) {
            int r = l * l + h * h;
            if (r == c) {
                return true;
            } else if (r > c) {
                h--;
            } else {
                l++;
            }
        }
        return false;
    }
}
